package com.yvan.periscope.service;

import com.yvan.periscope.domain.HistogramBean;
import com.yvan.periscope.domain.HistogramTitleEnum;
import org.joda.time.DateTime;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;

/**
 * @Author：BluesZhao
 * @Description：sql统计服务类
 * @Date： Create in 上午11:08 2018/8/17
 */
@Service
public class UrlsServiceImpl implements UrlsService {

    private static final String URLL_HISTOGRAM_INDEX_PATTERN = "per-uris-*";


    @Autowired
    private HistogramService histogramService;

    @Override
    public HistogramBean getUrlsHistogram(String histogramPrefix, DateTime dt1, DateTime dt2) throws IOException {
        HistogramTitleEnum histogramTitleEnum = HistogramTitleEnum.getEnum("url", histogramPrefix);
        return histogramService.findHistogramFromPeriscope(URLL_HISTOGRAM_INDEX_PATTERN, histogramPrefix,
                histogramTitleEnum.getPartition(), dt1, dt2,
                histogramTitleEnum.getxAxisTitle(), histogramTitleEnum.getyAxisTitle());
    }
}
